#include <QApplication>
#include <QPushButton>
#include <QFont>
#include <QVBoxLayout>
#include <QWidget>
#include "PhysiksDrawer.h"

using namespace PhysiksBase;

class MyWidget : public QWidget {
    public:
        MyWidget(QWidget *parent = NULL) : QWidget(parent) {
            QVBoxLayout *layout = new QVBoxLayout();
            QPushButton *exiter = new QPushButton("Exit");
            QPushButton *stepper = new QPushButton("Step");
            layout->addWidget(exiter);
            layout->addWidget(stepper);
            setLayout(layout);
            QObject::connect(exiter, SIGNAL(clicked()), qApp, SLOT(quit()));
            QObject::connect(stepper, SIGNAL(clicked()), parent, SLOT(updateGL()));
            exiter->resize(200, 50);
            stepper->resize(200, 50);
        }
};

int main(int argc, char *argv[]) {
    QApplication app(argc, argv);

    World *world = new World(3, 1.0E-1);
    Vector *pos1 = new Vector(3, 0.0);
    Vector *pos2 = new Vector(3, 0.0);
    Vector *vel1 = new Vector(3, 0.0);
    Vector *vel2 = new Vector(3, 0.0);
    //     pos1->set(1, 2.4);
    //     pos1->set(0, 2.4);
    vel1->set(0, 1.2);
    pos2->set(2, -4.5);
    pos2->set(0, 6.3781E6);
    PhysicalObject *obj1 = new PhysicalObject(45.5, 0.0, *pos1, *vel1);
    PhysicalObject *obj2 = new PhysicalObject(5.9742E24, 0.0, *pos2, *vel2);
    world->add_object(*obj1);
    world->add_object(*obj2);

    PhysiksDrawer *drawer1 = new PhysiksDrawer(NULL);
    MyWidget *wid = new MyWidget(drawer1);
    drawer1->resize(640, 640);
    drawer1->bindWorld(world);
    drawer1->show();
    int ret_val = app.exec();

    delete wid;

    return ret_val;
}
